2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #import "adiumGaimWebcam.h"
20 static void adiumGaimWebcamNew(GaimWebcam *gwc)
22 GaimDebug(@"adiumGaimWebcamNew");
26 // c = g_new0(GaimGtkWebcam, 1);
31 // c->button = gaim_pixbuf_button_from_stock(_("Close"), GTK_STOCK_CLOSE, GAIM_BUTTON_HORIZONTAL);
32 // c->vbox = gtk_vbox_new(FALSE, 0);
33 // gtk_box_pack_end_defaults(GTK_BOX(c->vbox), GTK_WIDGET(c->button));
35 // c->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
36 // tmp = g_strdup_printf(_("%s's Webcam"), gwc->name);
37 // gtk_window_set_title(GTK_WINDOW(c->window), tmp);
40 // gtk_container_add(GTK_CONTAINER(c->window), c->vbox);
42 // g_signal_connect(G_OBJECT(c->button), "clicked",
43 // G_CALLBACK(gaim_gtk_webcam_close_clicked), c);
45 // g_signal_connect(G_OBJECT(c->window), "destroy",
46 // G_CALLBACK(gaim_gtk_webcam_destroy), c);
48 // c->image = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO));
49 // gtk_box_pack_start_defaults(GTK_BOX(c->vbox), c->image);
50 // gtk_widget_show(GTK_WIDGET(c->image));
52 // gtk_widget_show(GTK_WIDGET(c->button));
53 // gtk_widget_show(GTK_WIDGET(c->vbox));
54 // gtk_widget_show(GTK_WIDGET(c->window));
57 static NSMutableData *frameData = nil;
59 static void adiumGaimWebcamUpdate(GaimWebcam *gwc,
60 const unsigned char *image, unsigned int size,
61 unsigned int timestamp, unsigned int id)
63 GaimDebug(@"adiumGaimWebcamUpdate (Frame %i , %i bytes)", id, size);
66 frameData = [[NSMutableData alloc] init];
69 [frameData appendBytes:image length:size];
71 // GaimGtkWebcam *cam;
75 // gaim_debug_misc("gtkwebcam", "Got %d bytes of frame %d.\n", size, id);
77 // cam = gwc->ui_data;
81 // f = wcframe_find_by_no(cam->frames, id);
83 // f = wcframe_new(cam, id);
84 // cam->frames = g_list_append(cam->frames, f);
87 // if (!gdk_pixbuf_loader_write(f->loader, image, size, &e)) {
88 // gaim_debug(GAIM_DEBUG_MISC, "gtkwebcam", "gdk_pixbuf_loader_write failed:%s\n", e->message);
93 static void adiumGaimWebcamFrameFinished(GaimWebcam *wc, unsigned int id)
95 GaimDebug(@"adiumGaimWebcamFrameFinished");
97 NSBitmapImageRep *rep;
98 rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **)[frameData bytes]
105 colorSpaceName:NSCalibratedRGBColorSpace
109 GaimDebug(@"rep = %@",rep);
111 // [[AIObject sharedAdiumInstance] performSelectorOnMainThread:@selector(showImage:) withObject:rep waitUntilDone:NO];
113 // NSImage *tmp = [[NSImage alloc] init];
114 // [tmp addRepresentation:rep];
122 [frameData release]; frameData = nil;
128 // GaimDebug(@"Bitmap?: %@",[NSImage initWithData:frameData]);
130 // GaimGtkWebcam *cam;
133 // cam = wc->ui_data;
136 // f = wcframe_find_by_no(cam->frames, id);
140 // gdk_pixbuf_loader_close(f->loader, NULL);
144 static void adiumGaimWebcamClose(GaimWebcam *gwc)
146 GaimDebug(@"adiumGaimWebcamClose");
147 // GaimGtkWebcam *cam;
149 // cam = gwc->ui_data;
154 // gwc->ui_data = NULL;
157 static void adiumGaimWebcamGotInvite(GaimConnection *gc, const gchar *who)
159 GaimDebug(@"adiumGaimWebcamGotInvite");
161 gaim_webcam_invite_accept(gc, who);
164 // gchar *str = g_strdup_printf(_("%s has invited you (%s) to view their Webcam."), who,
165 // gaim_connection_get_display_name(gc));
166 // struct _ggwc_gcaw *g = g_new0(struct _ggwc_gcaw, 1);
169 // g->who = g_strdup(who);
171 // gaim_request_action(gc, _("Webcam Invite"), str, _("Will you accept this invitation?"), 0,
172 // g, 2, _("Accept"), G_CALLBACK(_invite_accept), _("Decline"),
173 // G_CALLBACK(_invite_decline));
178 static struct gaim_webcam_ui_ops adiumGaimWebcamOps =
181 adiumGaimWebcamUpdate,
182 adiumGaimWebcamFrameFinished,
183 adiumGaimWebcamClose,
184 adiumGaimWebcamGotInvite
187 struct gaim_webcam_ui_ops *adium_gaim_webcam_get_ui_ops(void)
189 return &adiumGaimWebcamOps;
192 void initGaimWebcamSupport(void)
195 gaim_init_j2k_plugin();
198 gaim_webcam_set_ui_ops(adium_gaim_webcam_get_ui_ops());